package com.fr.lintcode;

import org.junit.Test;

/**
*作者：furong
*日期：2017年3月23日
*时间：下午5:31:24
*/
public class Q383 {
    /**
     * @param heights: an array of integers
     * @return: an integer
     */
    public int maxArea(int[] heights) {
        if (heights == null || heights.length <= 1) {
            return 0;
        }
        int max = 0;
        int n = heights.length;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                max = Math.max(max, (j - i) * Math.min(heights[i], heights[j]));
            }
        }
        return max;
    }

    @Test
    public void testA() {
        int heights[] = { 1, 2, 3 };
        System.out.println(maxArea(heights));

    }
}
